<template>
    <div>
        <h3>添加界面</h3>

        <table class="table">
            <tbody>
                <tr>
                    <td>名称</td>
                    <td>
                        <input type="text" v-model="data.Tname">
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input type="checkbox" v-model="data.Type">选中启用
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="button" value="添加" @click="add">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router=useRouter()

const data=ref({
  "Tid": 0,
  "Tname": "",
  "Type": null,
  "Tdate": "2025-04-14T01:40:59.650Z"
})

const add=()=>{
    axios.post("https://localhost:7228/api/HouseType/Add",data.value).then(res=>{
        if(res.data>0)
        {
            alert("添加成功");
            router.push({path:"/"})
        }
        else
        {
            alert("添加失败");
        }
    })
}

</script>

<style scoped>

</style>